<template>
    <div>
      <h1>商品列表</h1>
      <h1>类别ID:{{categoryId}}</h1>
      <ul v-for="item in itemList">
        <li>
          {{item.categoryId}}
        </li>
        <li>
          {{item.name}}
        </li>
      </ul>
    </div>
</template>

<script>
    export default {
        name: "ItemList",
        data(){
          return{
            categoryId:'',
            itemList:[]
          }
        },
        created() {
            //在created生命周期回调方法中接收上一个路由传递过来的参数
          this.categoryId = this.$route.query.categoryId
          this.getItemList()
        },
        methods:{
          //查询商品列表的方法
          getItemList:function(){
            this.axios.get('/product/list.do',{params:{'keyword':'i','categoryId':this.categoryId}})
              .then( (response) =>{
                console.log(response.data)
                this.itemList = response.data.data.list
              } )
          }
        }
    }
</script>

<style scoped>

</style>
